package com.vcaresolution.logistic.aspect;

import org.aspectj.lang.ProceedingJoinPoint;
import org.springframework.util.StopWatch;

/**
 * The <code>ProfilingAspect</code> is responsible for profiling (time log) for all database
 * operation in <b>ShipSoft</b> application.
 * 
 * @author Snehal Shah
 * @version 1.0
 * @since ShipSoft 1.0
 */
public class ProfilingAspect {

	public Object profile(ProceedingJoinPoint joinPoint) throws Throwable {
		StopWatch watch = new StopWatch();
		watch.start(joinPoint.getSignature().getName());
		try {
			return joinPoint.proceed(); //calling the target method
		}
		catch(Exception e) {
			throw e;
		}
		finally {
			watch.stop();
			
			//System.out.println("joinPoint :: "+joinPoint+"     "+watch.prettyPrint());
		}
	}
	
}
